<?php

class TreeController extends Zend_Controller_Action
{
	protected $_datas;
	
	public function init()
    {
	}

    public function treeAction($mode = null)
    {
		$this->mode = $this->_getParam("mode");
		switch($this->mode){
			case "generate":
				// generation du xml
				$treeManager = new CMS_TreeManager();
				$tree = $treeManager->toXml("tree", "directory_index");
				
				// creation du fichier
				$fileName = Zend_Registry::get('cms')->xml_path . "/" . Zend_Registry::get('cms')->tree_view_fileName;
				$f = new CMS_File($fileName);
				$f->write($tree);
				
				// redirection
				$this->_helper->redirectToOrigin();
				break;
			case "publish":
				// genere le fichier web d'inclusion de la nav
				$this->_helper->viewRenderer->setNoRender();
				break;
			case "app":
			case "html":
			case "form":
				$this->_helper->layout->disableLayout();
				$this->view->assign('mode', $this->mode);
				$this->view->assign('xml', Zend_Registry::get('cms')->xml_path . "/" . Zend_Registry::get('cms')->tree_view_fileName);
				break;
			default:
				$this->_helper->redirectToOrigin();
				break;
		}
	}
	
	public function testAction (){
		$this->view->assign('title', 'My 1st List view');
	}


}

